home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / ebksrc.zip / PCVIDEO.CPP < prev    next >
C/C++ Source or Header  |  1991-07-30  |  3KB  |  169 lines

  1. /*
  2.  
  3.     pcvideo.cpp
  4.     7-30-91
  5.     Extended text attribute control for conio.
  6.  
  7.     Copyright 1991
  8.     John W. Small
  9.     All rights reserved
  10.     Use freely but acknowledge authorship and copyright.
  11.  
  12.     PSW / Power SoftWare
  13.     P.O. Box 10072
  14.     McLean, Virginia 22102 8072 USA
  15.  
  16.     John Small
  17.     Voice: (703) 759-3838
  18.     CIS: 73757,2233
  19.  
  20. */
  21.  
  22. #include <dos.h>
  23. #include <pcvideo.hpp>
  24.  
  25.  
  26. int  forcedmonochrome = 0;
  27. static int prevattr = svideo(WHITE,BLACK);
  28. static int origattr = svideo(WHITE,BLACK);
  29.  
  30.  
  31. void reversevideo()
  32. {
  33.     struct text_info ti;
  34.  
  35.     gettextinfo(&ti);
  36.     prevattr = ti.attribute;
  37.     textattr(rvideo(ti.attribute));
  38. }
  39.  
  40. void blinkvideo()
  41. {
  42.     struct text_info ti;
  43.  
  44.     gettextinfo(&ti);
  45.     prevattr = ti.attribute;
  46.     textattr(bvideo(ti.attribute));
  47. }
  48.  
  49. void unblinkvideo(void)
  50. {
  51.     struct text_info ti;
  52.  
  53.     gettextinfo(&ti);
  54.     prevattr = ti.attribute;
  55.     textattr(ubvideo(ti.attribute));
  56. }
  57.  
  58. void savevideo()
  59. {
  60.     struct text_info ti;
  61.  
  62.     gettextinfo(&ti);
  63.     prevattr = ti.attribute;
  64. }
  65.  
  66. void restorevideo()
  67. {
  68.     struct text_info ti;
  69.     int oldprevattr = prevattr;
  70.  
  71.     gettextinfo(&ti);
  72.     prevattr = ti.attribute;
  73.     textattr(oldprevattr);
  74. }
  75.  
  76. void saveAsOrigVideo()
  77. {
  78.     struct text_info ti;
  79.  
  80.     gettextinfo(&ti);
  81.     origattr = ti.attribute;
  82. }
  83.  
  84. void restoreOrigVideo()
  85. {
  86.     struct text_info ti;
  87.     int oldorigattr = origattr;
  88.  
  89.     gettextinfo(&ti);
  90.     origattr = ti.attribute;
  91.     textattr(oldorigattr);
  92. }
  93.  
  94.  
  95. void putvideo(int left, int top, int right,
  96.     int bottom, int attr, int buf[])
  97. {
  98.     int y, len, i;
  99.     char attrch = (char) attr;
  100.     char *cbuf = (char *) buf;
  101.  
  102.     len = (right - left + 1) * 2;
  103.     for (y = top; y <= bottom; y++)  {
  104.         gettext(left,y,right,y,cbuf);
  105.         for (i = 1; i < len; i += 2)
  106.             cbuf[i] = attrch;
  107.         puttext(left,y,right,y,cbuf);
  108.     }
  109. }
  110.  
  111. int  istext()
  112. {
  113.     _AH = 0x0F;
  114.     geninterrupt(0x10);
  115.     switch (_AL)  {
  116.         case 0:
  117.         case 1:
  118.         case 2:
  119.         case 3:
  120.         case 7:
  121.             return 1;
  122.     }
  123.     return 0;
  124. }
  125.  
  126. int  iscolor()
  127. {
  128.     if (forcedmonochrome)
  129.         return 0;
  130.     _AH = 0x0F;
  131.     geninterrupt(0x10);
  132.     switch (_AL)  {
  133.         case 0:
  134.         case 2:
  135.         case 5:
  136.         case 6:
  137.         case 7:
  138.         case 15:
  139.         case 17:
  140.             return 0;
  141.             // must be 0 for mappalette
  142.     }
  143.     return 1;  // must be 1 for mappalette
  144. }
  145.  
  146. void toggleRes()
  147. {
  148.     struct text_info ti;
  149.  
  150.     gettextinfo(&ti);
  151.     switch (ti.currmode)  {
  152.     case C80:
  153.           textmode(C4350);
  154.           break;
  155.     case C4350:
  156.         textmode(C80);
  157.         break;
  158.     }
  159. }
  160.  
  161. void mapvideo(int attr_id, PalettE P)
  162. {
  163.     struct text_info ti;
  164.  
  165.     gettextinfo(&ti);
  166.     prevattr = ti.attribute;
  167.     textattr(mapattr(attr_id,P));
  168. }
  169.